<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion2.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
		date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
		$usuario = $_SESSION['name'];
		$fecha = date("Y-m-d H:i:s");
		$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Registro estudiante regular liceo' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}
include("conexion.php");

//alumno
$cedula=$_GET['cedula'];
$lapso=$_GET['lapso'];

if($cedula){
	if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; $periodo="$anio - $anio2"; } else{ $anio=date(Y)-1; $anio2=$anio+1; $periodo="$anio - $anio2"; }
	$est = mysql_fetch_array(mysql_query("SELECT inscripcion.periodo, alumno.CI_a, alumno.nombre_a, alumno.apellido_a, inscripcion.grado, inscripcion.seccion FROM alumno INNER JOIN inscripcion ON alumno.CI_a=inscripcion.cedula_a WHERE alumno.CI_a='$cedula' "));
	$mat_pend = mysql_fetch_array(mysql_query("SELECT Cod_m, nombre_m, ano_m from materia inner join inscripcion on cod_m=mat_pend_1 where cedula_a='$cedula' and periodo='$periodo' order by grado desc limit 1"));
	$mat_pend2 = mysql_fetch_array(mysql_query("SELECT Cod_m, nombre_m, ano_m from materia inner join inscripcion on cod_m=mat_pend_2 where cedula_a='$cedula' and periodo='$periodo' order by grado desc limit 1"));
	
		if($lapso == '1er Lapso'){
			$nota_mat = mysql_fetch_array(mysql_query("SELECT nota1 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend[0]' "));
			$nota_mat2 = mysql_fetch_array(mysql_query("SELECT nota1 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend2[0]' "));
		}else if($lapso == '2do Lapso'){
			$nota_mat = mysql_fetch_array(mysql_query("SELECT nota2 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend[0]' "));
			$nota_mat2 = mysql_fetch_array(mysql_query("SELECT nota2 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend2[0]' "));
		}else if($lapso == '3er Lapso'){
			$nota_mat = mysql_fetch_array(mysql_query("SELECT nota3 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend[0]' "));
			$nota_mat2 = mysql_fetch_array(mysql_query("SELECT nota3 FROM alumno_matpend WHERE cedula='$cedula' AND mat_pend='$mat_pend2[0]' "));
		}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Materia Pendiente</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="js/valida_ar.js" type="text/javascript"></script><script src="css/stuHover.js" type="text/javascript"></script>
<script src="js/prototype.js" type="text/javascript"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

function comprobar_a()
{  
  var url = 'http://127.0.0.1/sistema/sistema_liceo/comprobar_a.php';
  var pars= ('cedula=' + document.getElementById('cedula').value);
  var myAjax = new Ajax.Updater( 'comprobar_mensaje_a', url, { method: 'get', parameters: pars});
}

var nav4 = window.Event ? true : false;
function acceptNum(evt){   
var key = nav4 ? evt.which : evt.keyCode;   
return (key <= 13 || (key>= 48 && key <= 57));
}

function ComprobarAsistencia(valor){    
	if(valor.value > 20){
		valor.value="";
        valor.focus();
	return false;
	}
	else{
		return true;
	}
}

function Pasar(cedula) {
   var lapso = document.est.lapso.value;
   document.location='NotaMatPend.php?cedula='+cedula+'&lapso='+lapso;
}

function verifyInput(_selList,_textBox,pos) {
	document.getElementById('cedula').readOnly = false;
	var SI = eval(_selList+".selectedIndex");
	var SV = eval(_selList+".options[SI].value");
	eval(_textBox+".value = SV");
	var a = eval(_selList+".options.selectedIndex=0");
	if (pos=='0'){
		document.buscador.cedula.focus();
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">MATERIA PENDIENTE</h2></blockquote>
		<fieldset>
		<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
			<form action=NotaMatPend.php method=get name='buscador'>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr align=center>
					<td width=50% align=center>C&eacute;dula: <select name='Nac_e' onchange="verifyInput('document.buscador.Nac_e','document.buscador.cedula','0')"><option></option><option value='V-'>V-</option><option value='E-'>E-</option></select><input name='cedula' id='cedula' onKeyUp='comprobar_a(this.value)' onKeyPress='return acceptNum(event)' size=8 maxlength=10 readonly>
					<input class=button type=submit value=Buscar><br><span id='comprobar_mensaje_a'></span></td>
				</tr>
			</table>
			</form>
		</fieldset>
		

<div class="post">
<span></span></div>

<?php if($est && $mat_pend){
echo "
	<fieldset>
	<legend align=left><b><font size=2>ESTUDIANTE</font></b></legend>
		<form action=ResNotaMatPend.php method=post name=est>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=50%>Per&iacute;odo: </td><td>$est[0]</td>
			</tr>
			<tr>
				<td>C&eacute;dula: </td><td>$est[1]</td>
				<input name=cedula type=hidden value='$est[1]'>
			</tr>
			<tr>
				<td>Nombres: </td><td>$est[2]</td>
			</tr>
			<tr>	
				<td>Apellidos: </td><td>$est[3]</td>
			</tr>
			<tr>	
				<td>Grado </td><td>$est[4]</td>
			</tr>
			<tr>
				<td>Secci&oacute;n </td><td>$est[5]</td>
			</tr>
		</table>
	</fieldset>

<div class=post>
<span></span></div>

<div align=center><select name=lapso id=lapso onChange='Pasar($cedula);'><option>Lapso</option>
			<option ";if ($lapso=='1er Lapso'){ echo "Selected"; } echo">1er Lapso</option>
			<option ";if ($lapso=='2do Lapso'){ echo "Selected"; } echo">2do Lapso</option>
			<option ";if ($lapso=='3er Lapso'){ echo "Selected"; } echo">3er Lapso</option></select></div>

<fieldset>
	<legend align=left><b><font size=2>NOTA ".strtoupper($lapso)."</font></b></legend>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<th>Grado</th><th>Materia</th><th>Nota</th>
			</tr>
			<tr align=center>
				<td>$mat_pend[2]</td><td>$mat_pend[1]</td><td><input type=text size=3 value='$nota_mat[0]' name='mat_p1' onKeyPress=\"return acceptNum(event)\" onkeyup=\"ComprobarAsistencia(this)\"></td>
			</tr>
			<tr align=center>
				<td>$mat_pend2[2]</td><td>$mat_pend2[1]</td><td><input type=text size=3 value='$nota_mat2[0]' name='mat_p2' onKeyPress=\"return acceptNum(event)\" onkeyup=\"ComprobarAsistencia(this)\"></td>
			</tr>
			<input type=hidden name='cod_mat1' value='$mat_pend[0]'>
			<input type=hidden name='cod_mat2' value='$mat_pend2[0]'>
			<input type=hidden name='lapsos' value='$lapso'>
		</table>
	</fieldset>

<div class=post>
<span></span></div>

<div id=botonera align=center>
	<input class=button type=submit value=Guardar>
	<input class=button type=button value=Cancelar onClick=location='index.php'>
</div>";
}else if($cedula && $mat_pend[1] == ''){
	echo "<script>alert('El estudiante no tiene materia(s) pendiente(s).');</script>";
	echo "<script>document.location.href='index.php';</script>";
}
 ?>
</form>
</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
